home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / contrib / zelk / src-zelk / MIPSASM.s < prev    next >
Encoding:
Text File  |  1992-10-17  |  1.5 KB  |  82 lines

  1.  # MIPSASM.s zilla 17apr  working version!
  2.  # mod 
  3.  # 23apr return float as well as double
  4.  #
  5.  # If float (not double) stops working, be sure code is compiled
  6.  # with ansi or -prototypes.
  7.  #
  8.  #  double FA_d1,FA_d2;
  9.  #  int FA_reg[4];
  10.  #  int FA_stk[12];
  11.     .verstamp    2 40
  12.  
  13.     .comm    FA_d1 8
  14.     .comm    FA_d2 8
  15.     .comm    FA_reg 16
  16.     .comm    FA_stk 48    # 4*FA_MAX
  17.     .comm    FA_drtn 8
  18.     .comm    FA_frtn 4
  19.     .comm    FA_irtn 4
  20.  
  21.     .text    
  22.     .align    2
  23.     .file    2 "FORMIPS.s"
  24.     .globl    ZLforcall2
  25.  
  26.     .ent    ZLforcall2 2
  27. ZLforcall2:
  28.     .option    O2
  29.     subu    $sp, 56
  30.     sw    $31, 52($sp)
  31.     .mask    0x80000000, -4
  32.     .frame    $sp, 56, $31
  33.     .loc 2 1
  34.  
  35.     move $10, $4        # save arg1=func in $10
  36.  
  37.  #      FA_drtn = (*func)(FA_d1,FA_reg[2],FA_reg[3],
  38.  #          FA_stk[4],FA_stk[5],FA_stk[6],FA_stk[7],FA_stk[8],FA_stk[9],
  39.  #                        FA_stk[10],FA_stk[11]);
  40.     .loc 2 2
  41.  
  42.     l.d    $f12, FA_d1    # leading 2 double args
  43.     l.d    $f14, FA_d2
  44.  #    .loc 2 3
  45.  
  46.     lw    $4, FA_reg    # first 4 args in registers
  47.     lw    $5, FA_reg+4
  48.     lw    $6, FA_reg+8
  49.     lw    $7, FA_reg+12
  50.  #    .loc 2 4
  51.  
  52.     lw    $14, FA_stk+16    # remaining args on stack
  53.     sw    $14, 16($sp)
  54.     lw    $14, FA_stk+20
  55.     sw    $14, 20($sp)
  56.     lw    $14, FA_stk+24
  57.     sw    $14, 24($sp)
  58.     lw    $14, FA_stk+28
  59.     sw    $14, 28($sp)
  60.  #    .loc 2 5
  61.     lw    $14 FA_stk+32
  62.     sw    $14, 32($sp)
  63.     lw    $14, FA_stk+36
  64.     sw    $14, 36($sp)
  65.     lw    $14, FA_stk+40
  66.     sw    $14, 40($sp)
  67.     lw    $14, FA_stk+44
  68.     sw    $14, 44($sp)
  69.  #    .loc 2 6
  70.  
  71.     .livereg    0x0300000E,0x000C0000
  72.     jal    $10
  73.     sw     $2, FA_irtn        # returned int in $2
  74.     s.d     $f0, FA_drtn        # returned dbl in $f0
  75.     s.s     $f0, FA_frtn        # returned flt in $f0
  76.  
  77.     .livereg    0x2000FF0E,0x00000FFF
  78.     lw    $31, 52($sp)
  79.     addu    $sp, 56
  80.     j    $31
  81.     .end    ZLforcall2
  82.